﻿using System;
using System.Collections.Generic;
using System.Text;

public class Triple : ICloneable, IComparable<Triple>
{
    private int a;
    private int b;
    private int c;

    public Triple(int a, int b, int c)
    {
        this.a = a;
        this.b = b;
        this.c = c;
    }

    public int CompareTo(Triple other)
    {
        int thisSum = this.A + this.B + this.C;
        int otherSum = other.A + other.B + other.C;
        int result = thisSum.CompareTo(otherSum);
        return result;
    }

    public object Clone()
    {
        object cloned = this.MemberwiseClone();
        return cloned;
    }

    public int A
    {
        get
        {
            return a;
        }
        set
        {
            a = value;
        }
    }
    public int B
    {
        get
        {
            return b;
        }
        set
        {
            b = value;
        }
    }
    public int C
    {
        get
        {
            return c;
        }
        set
        {
            c = value;
        }
    }

    public static Triple operator +(Triple first, Triple second)
    {
        int sumOfA = first.A + second.A;
        int sumOfB = first.B + second.B;
        int sumOfC = first.C + second.C;
        Triple result = new Triple(sumOfA, sumOfB, sumOfC);
        return result;
    }

    public static Triple operator -(Triple first, Triple second)
    {
        int differenceOfA = first.A - second.A;
        int differenceOfB = first.B - second.B;
        int differenceOfC = first.C - second.C;
        Triple result = new Triple(differenceOfA, differenceOfB, differenceOfC);
        return result;
    }

    public static Triple operator ++(Triple triple)
    {
        int incrementedA = triple.A + 1;
        int incrementedB = triple.B + 1;
        int incrementedC = triple.C + 1;
        Triple result = new Triple(incrementedA, incrementedB, incrementedC);
        return result;
    }
}

public static class Extension
{
    public static string AsString(this IEnumerable<Triple> collection)
    {
        StringBuilder builder = new StringBuilder();
        foreach (var triple in collection)
        {
            builder.AppendFormat("A= {0}, B= {1}, C= {2}", triple.A, triple.B, triple.C);
            builder.Append("\n");
        }
        return builder.ToString();
    }
}